<settings-screen>
    <div class="row">
        <div class="col-md-offset-4 col-md-4">
            <h3 class="m-t-0">General</h3>
            <p>
                <label>
                    Date Format
                </label>
                <select class="form-control" ng-model="$ctrl.settings.date_format" ng-change="$ctrl.update('date_format')">
                    <option value="DD/MM/YY">DD/MM/YY</option>
                    <option value="MM/DD/YY">MM/DD/YY</option>
                    <option value="YYYY-MM-DD">YYYY-MM-DD</option>
                </select>
            </p>
            <hr>
            <h3>Authentication</h3>
            <p>
                <label>
                    <input name="input" type="checkbox" ng-model="$ctrl.settings.auth_password_login_enabled" ng-change="$ctrl.update('auth_password_login_enabled')"
                        accesskey="tab" ng-disabled="$ctrl.disablePasswordLoginToggle()"> Password Login Enabled
                    <span uib-popover="Password login can be disabled only if another login method is enabled." popover-trigger="'mouseenter'"
                        ng-if="$ctrl.disablePasswordLoginToggle()">
                        <i class="fa fa-question-circle"></i>
                    </span>
                </label>

                <div class="callout callout-warning" ng-if="!$ctrl.settings.auth_password_login_enabled">
                    Password based login is currently disabled and users will be able to login only with the enabled SSO options.
                </div>
            </p>

            <div ng-if="$ctrl.googleLoginEnabled">
                <h4>Google Login</h4>
                <label>
                    Allowed Google Apps Domains
                </label>
                <ui-select multiple tagging tagging-label="false" ng-model="$ctrl.settings.auth_google_apps_domains" tagging-tokens="SPACE|,"
                    title="Google Apps Domain(s)"
                    ng-change="$ctrl.update('auth_google_apps_domains')">
                    <ui-select-match placeholder="Google Apps Domain(s)">{{$item}}</ui-select-match>
                    <!-- the ui-select-choices is here just to make ui-select work -->
                    <ui-select-choices repeat="domain in $ctrl.domains">
                        {{domain}}
                    </ui-select-choices>
                </ui-select>

                <div class="callout callout-info m-t-5" ng-if="$ctrl.settings.auth_google_apps_domains | notEmpty">
                    Any user registered with a <strong>{{$ctrl.settings.auth_google_apps_domains | join}}</strong> Google Apps account will be able to login. If they don't have an existing user, a new user will be created and join the <strong>Default</strong> group.
                </div>
            </div>

            <h4>SAML</h4>
            <p>
                <label>
                    <input name="input" type="checkbox" ng-model="$ctrl.settings.auth_saml_enabled" ng-change="$ctrl.update('auth_saml_enabled')"
                        accesskey="tab"> SAML Enabled
                </label>

                <div ng-show="$ctrl.settings.auth_saml_enabled">
                    <div class="form-group">
                        <label>SAML Metadata URL</label>
                        <input name="input" type="string" class="form-control" ng-model="$ctrl.settings.auth_saml_metadata_url" accesskey="tab" ng-change="$ctrl.update('auth_saml_metadata_url')"
                            ng-model-options="{ debounce: 200 }">
                    </div>
                    <div class="form-group">
                        <label>SAML Entity ID</label>
                        <input name="input" type="string" class="form-control" ng-model="$ctrl.settings.auth_saml_entity_id" accesskey="tab" ng-change="$ctrl.update('auth_saml_entity_id')"
                            ng-model-options="{ debounce: 200 }">
                    </div>
                    <div class="form-group">
                        <label>SAML NameID Format</label>
                        <input name="input" type="string" class="form-control" ng-model="$ctrl.settings.auth_saml_nameid_format" accesskey="tab"
                            ng-change="$ctrl.update('auth_saml_nameid_format')" ng-model-options="{ debounce: 200 }">
                    </div>
                </div>
            </p>
        </div>
    </div>
</settings-screen>